package com.xtwy.qrcodescan;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.xtwy.qrcodescan.utils.Constant;

import butterknife.ButterKnife;
import butterknife.OnClick;

/*
 * -----------------------------------------------------------------
 * Copyright (C) 2014-2016, by your company, All rights reserved.
 * -----------------------------------------------------------------
 * 文    件: MainActivity.java
 * 作    者: 侯建军
 * 版    权: 1.0.0
 * 描    述: 
 * 创建时间: 2018/9/14 14:01
 * 更新时间：2018/9/14 14:01
 * -----------------------------------------------------------------
 * 2018/9/14 14:01 : 创建 MainActivity.java (侯建军);
 * -----------------------------------------------------------------
 */
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //绑定activity
        ButterKnife.bind( this ) ;
        int mode = getIntent().getIntExtra(Constant.REQUEST_SCAN_MODE, Constant.REQUEST_SCAN_MODE_ALL_MODE);
    }

    /**
     * 按钮监听事件
     * @param view
     */
    @OnClick({R.id.create_code,R.id.scan_2code,R.id.scan_bar_code,R.id.scan_code,R.id.net_access})
    public void clickListener(View view){
        Intent intent;
        switch (view.getId()){
            case  R.id.create_code: //生成码
                intent=new Intent(this,CreateCodeActivity.class);
                startActivity(intent);
                break;
            case  R.id.scan_2code:
                //扫描二维码
                intent=new Intent(this,CommonScanActivity.class);
                //参数传递，第二个参数为扫码类型
                intent.putExtra(Constant.REQUEST_SCAN_MODE,Constant.REQUEST_SCAN_MODE_QRCODE_MODE);
                startActivity(intent);
                break;
            case  R.id.scan_bar_code:
                //扫描条形码
                intent=new Intent(this,CommonScanActivity.class);
                intent.putExtra(Constant.REQUEST_SCAN_MODE,Constant.REQUEST_SCAN_MODE_BARCODE_MODE);
                startActivity(intent);
                break;
            case  R.id.scan_code:
                //扫描条形码或者二维码
                intent=new Intent(this,CommonScanActivity.class);
                intent.putExtra(Constant.REQUEST_SCAN_MODE,Constant.REQUEST_SCAN_MODE_ALL_MODE);
                startActivity(intent);
                break;
            case  R.id.net_access:
                //访问网络
                intent=new Intent(this,NetActivity.class);
                startActivity(intent);
                break;
        }
    }
}
